package com.project.xsf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.common.entity.PageVo;
import com.project.xsf.entity.MProcedure;
import com.project.xsf.entity.MProcedureModule;
import com.project.xsf.mapper.MProcedureModuleMapper;
import com.project.xsf.service.MProcedureModuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class MProcedureModuleImpl implements MProcedureModuleService {
    @Autowired
    private MProcedureModuleMapper mProcedureModuleMapper;
    @Override
    public int insertSelective(MProcedureModule record) {
        return mProcedureModuleMapper.insertSelective(record);
    }

    @Override
    public PageVo<MProcedureModule> queryMProcedureModuleByPId(Map<String, String> map) {
        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize= Integer.valueOf(map.get("pageSize"));
//        System.out.println(map);
        PageHelper.startPage(pageNum,pageSize);
        List<MProcedureModule> mProcedureModules = mProcedureModuleMapper.queryMProcedureModuleByPId(Integer.valueOf(map.get("pId")));
        PageInfo<MProcedureModule> pageInfo = new PageInfo<MProcedureModule>(mProcedureModules);

        PageVo<MProcedureModule> pageVo = new PageVo<MProcedureModule>();
        pageVo.setRows(pageInfo.getList());
        pageVo.setTotal(pageInfo.getTotal());

        return pageVo;
    }

    @Override
    public List<MProcedureModule> queryMProcedureModuleByPId(Integer pId) {
        return mProcedureModuleMapper.queryMProcedureModuleByPId(pId);
    }

    @Override
    public List<MProcedureModule> queryMProcedureModuleByMManufactureId(Integer mManufactureId) {
        return mProcedureModuleMapper.queryMProcedureModuleByMManufactureId(mManufactureId);
    }

    @Override
    public MProcedureModule selectByPrimaryKey(Integer id) {
        return mProcedureModuleMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(MProcedureModule record) {
        return mProcedureModuleMapper.updateByPrimaryKeySelective(record);
    }


}
